package com.excel.demo.excel.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
 * @ClassName uploadThreadingConfig
 * @Description TODO
 * @Author Administrator
 * @Date 2022/4/13 12:09
 * @Version 1.0
 */
@Configuration
public class UploadThreadingConfig {

    @Bean("uploadThreadPool")
    public Executor uploadThreadPool() {
        ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
        taskExecutor.setMaxPoolSize(16);
        taskExecutor.setCorePoolSize(8);
        taskExecutor.setQueueCapacity(8);
        taskExecutor.setThreadNamePrefix("Application Thread-");
        taskExecutor.setKeepAliveSeconds(60*2);//空闲两分钟回收
        taskExecutor.initialize();
        return taskExecutor;
    }

}
